package model;

public class WordModel {

	private String sentencePolish;
	private String sentenceForeign;
	private String sentenceDisplay;
	private String sentenceCorrect;
	
	private String wordPolish;
	private String wordForeign;
	private String wordDisplay;
	private String wordCorrect;
	
	private boolean used;
	private float mark;
	
	private boolean polishToForeignMode;

	public WordModel(String polish, String foreign, boolean polishToForeignMode)
	{
		this.wordPolish = polish;
		this.wordForeign = foreign;
		this.setUnused();
		this.mark = 0;

		this.polishToForeignMode = polishToForeignMode;
		
		this.wordDisplay = this.polishToForeignMode ? this.wordPolish : this.wordForeign;
		this.wordCorrect = this.polishToForeignMode ? this.wordForeign : this.wordPolish;
	}

	public void setSentences(String polish, String foreign) {
		this.sentencePolish = polish;
		this.sentenceForeign = foreign;
		
		this.sentenceDisplay = polishToForeignMode ? this.sentencePolish : this.sentenceForeign;
		this.sentenceCorrect = polishToForeignMode ? this.sentenceForeign : this.sentencePolish;
	}

	public boolean isSentenceSet() {
		return this.sentenceDisplay != null && this.sentenceCorrect != null;
	}
	
	public String getSentenceDisplay() {
		return sentenceDisplay;
	}

	public String getSentenceCorrect() {
		return sentenceCorrect;
	}

	public String getDisplay() {
		return wordDisplay;
	}

	public String getCorrect() {
		return wordCorrect;
	}

	public boolean isUsed() {
		return used;
	}

	public void setUsed() {
		this.used = true;
	}

	public void setUnused()
	{
		this.used = false;
	}

	public void revertMode()
	{
		this.wordDisplay = polishToForeignMode ? wordForeign : wordPolish;
		this.wordCorrect = polishToForeignMode ? wordPolish : wordForeign;
		this.sentenceDisplay = polishToForeignMode ? sentenceForeign : sentencePolish;
		this.sentenceCorrect = polishToForeignMode ? sentencePolish : sentenceForeign;
		polishToForeignMode = !polishToForeignMode;
	}

	public void setMark(float mark) {
		if (mark >= 0 && mark <= 1) {
			this.mark = mark;
		}
	}

	public float getMark()
	{
		return mark;
	}

	@Override
	public String toString() {
		return "WordModel [sentencePolish=" + sentencePolish
				+ ", sentenceForeign=" + sentenceForeign + ", sentenceDisplay="
				+ sentenceDisplay + ", sentenceCorrect=" + sentenceCorrect
				+ ", wordPolish=" + wordPolish + ", wordForeign=" + wordForeign
				+ ", wordDisplay=" + wordDisplay + ", wordCorrect="
				+ wordCorrect + ", used=" + used + ", mark=" + mark
				+ ", polishToForeignMode=" + polishToForeignMode + "]";
	}
}